﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;

/// <summary>
/// Summary description for MessageBox
/// </summary>
public static class MessageBox
{

    private static StringBuilder sb;
    public static void Show(string strMessage)
    {

        sb = new StringBuilder();
        strMessage = strMessage.Replace("\n", "\\n");
        strMessage = strMessage.Replace("\"", "'");
        sb.Append("<script language=\"javascript\" type=\"text/javascript\">");
        sb.Append(@"alert( """ + strMessage + @""" );");
        sb.Append(@"</script>");
        Page pgExecutingPage = HttpContext.Current.Handler as Page;
        pgExecutingPage.Unload += new EventHandler(pgExecutingPage_Unload);
    }
    private static void pgExecutingPage_Unload(object sender, EventArgs e)
    {

        HttpContext.Current.Response.Write(sb);
    }
}